//
//  CCMeshBase.h
//  ShadowMapping
//
//  Created by Daniel Corleone on 5/6/14.
//  Copyright (c) 2014年 iCloverStudio. All rights reserved.
//

#ifndef __ShadowMapping__CCMeshBase__
#define __ShadowMapping__CCMeshBase__

#if defined(__APPLE__) || defined(__MAC_OSX__)
#include <OpenGL/gl.h>

#elif defined(_WIN32)
#include <GL\glew.h>

#endif	//

#include "PlatformFeatures.h"
#include "CCDataType.h"
#include "CCNode.h"

BECO_NAMESPACE_BEGIN

class Mesh : public Node {
private:
    // Our vertex buffer.
    Real *verticesBuffer;
    
    // Our index buffer.
    Int32 *indicesBuffer;
    
    // The number of indices.
	Int32 numOfIndices = -1;
    
    // Flat Color
    Real rgba[4];
    
    // Smooth Colors
    Real *colorBuffer;
    
public:
//    // Translate params.
//    Real x = 0;
//    Real y = 0;
//    Real z = 0;
//    
//    // Rotate params.
//    Real rx = 0;
//    Real ry = 0;
//    Real rz = 0;
    
public:
    explicit Mesh(const String& name);
    explicit Mesh(Node* parent, const String& name);
    virtual ~Mesh();
    
	virtual void Update(const Real timeInterval);
    virtual void Render(const Real timeInterval);
    
protected:
	void setVertices(Real *vertices, const Int32 length);
	void setIndices(Int32 *indices, const Int32 length);
    
    void setColor(Real red, Real green,
                  Real blue, Real alpha);
    
	void setColors(Real *colors, const Int32 length);
};

BECO_NAMESPACE_END

#endif /* defined(__ShadowMapping__CCMeshBase__) */
